package tgc.edu.fhh.service;



import java.util.List;
import java.util.Optional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;

import tgc.edu.fhh.entity.SysDept;
import tgc.edu.fhh.repository.SysDeptRepository;

@Service
public class SysDeptService {
	
	@Autowired
	private SysDeptRepository sysDeptRepository;

	public <S extends SysDept> S save(S entity) {
		return sysDeptRepository.save(entity);
	}

	public Page<SysDept> findAll(Pageable pageable) {
		return sysDeptRepository.findAll(pageable);
	}

	public List<SysDept> findAll() {
		return sysDeptRepository.findAll();
	}

	public List<SysDept> findAll(Sort sort) {
		return sysDeptRepository.findAll(sort);
	}

	public List<SysDept> findAll(Specification<SysDept> spec) {
		return sysDeptRepository.findAll(spec);
	}

	public List<SysDept> findAllById(Iterable<Integer> ids) {
		return sysDeptRepository.findAllById(ids);
	}

	public Page<SysDept> findAll(Specification<SysDept> spec, Pageable pageable) {
		return sysDeptRepository.findAll(spec, pageable);
	}

	public SysDept findById(Integer id) {
		 Optional<SysDept> optional = sysDeptRepository.findById(id);
		 if(optional.isPresent()) {
			 return optional.get();
		 }
		 return null;
	}

	public List<SysDept> findAll(Specification<SysDept> spec, Sort sort) {
		return sysDeptRepository.findAll(spec, sort);
	}

	public <S extends SysDept> Page<S> findAll(Example<S> example, Pageable pageable) {
		return sysDeptRepository.findAll(example, pageable);
	}

	public SysDept getOne(Integer id) {
		return sysDeptRepository.getOne(id);
	}

	public <S extends SysDept> List<S> findAll(Example<S> example) {
		return sysDeptRepository.findAll(example);
	}

	public long count() {
		return sysDeptRepository.count();
	}

	public void deleteById(Integer id) {
		sysDeptRepository.deleteById(id);
	}

	public <S extends SysDept> List<S> findAll(Example<S> example, Sort sort) {
		return sysDeptRepository.findAll(example, sort);
	}

	public void delete(SysDept entity) {
		sysDeptRepository.delete(entity);
	}
	
	
	
	

}
